//
//  MLWTipsICookOtherTableViewCell.m
//  KITCHEN_STORIES
//
//  Created by 孟令通 on 16/6/14.
//  Copyright © 2016年 MLW. All rights reserved.
//

#import "MLWTipsICookOtherTableViewCell.h"

#import "MLWBaseView.h"

@implementation MLWTipsICookOtherTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.mainImageView = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_mainImageView];
        [_mainImageView release];
        
        self.title = [[UILabel alloc] init];
        [self.title setFont:[UIFont systemFontOfSize:14]];
        
        [self.contentView addSubview:_title];
        [_title release];
        
        
        self.discription  = [[UILabel alloc] init];
        [self.discription setFont:[UIFont systemFontOfSize:14]];
        self.discription.textColor = [UIColor colorWithRed:0.37 green:0.37 blue:0.37 alpha:1.00];
        
        [self.contentView addSubview:_discription];
        [_discription release];
        
        
    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.mainImageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(20);
        
        make.top.equalTo(self.contentView).offset(10);
        
        make.width.equalTo(50);
        
        make.height.equalTo(50);
        
    }];
    self.mainImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.mainImageView.clipsToBounds = YES;
    
    [self.title makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mainImageView.right).offset(11.5);
        
        make.top.equalTo(self.contentView).offset(10);
        
        make.height.equalTo(20);
        
        make.right.equalTo(self.contentView).offset(-10);
        
    }];
    
    [self.discription makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mainImageView.right).offset(11.5);
        
        make.top.equalTo(self.title.bottom).offset(0);
        
        make.height.equalTo(20);
        
        make.right.equalTo(self.contentView).offset(-10);
        
    }];
    
}

-(void)setModel:(MLWTipsICookOtherSuitableModel *)model
{
    if (_model != model) {
        
        [_model release];
        
        _model = [model retain];
        
        [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageNamed:@"placeholder"]];
        
        self.title.text = model.material_name;
        
        self.discription.text = model.suitable_desc;
        
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
